<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>07-5秒之后自定关闭的广告</title>
</head>

<body>
  <img src="images/ad.jpg" alt="" class="ad">
  <script>
    var ad = document.querySelector('.ad');
    setTimeout(function () {
      ad.style.display = 'none';
      console.log('成功隐藏');
    }, 5000);
  </script>
</body>

</html>